% Chakram is a subproject of Hexena - Haskell Executable Analyser
% License:			GPL-3
% Maintainer:		Montez Fitzpatrick
% Stability:		Experimental
% Portability:		GHC
% Module:			Hexena.Data.MzHeader

This module can read and write MZ Headers.
\begin{code}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Hexena.Data.MzHeader 
	(
	-- * Data Structures
	  MzHeader(..)
	, Res1(..)
	, Res2(..)
	) where

import Data.Word
import Data.Label -- Needs 'fclabels'

sIZE_OF_IMAGE_DOS_HEADER :: Int
sIZE_OF_IMAGE_DOS_HEADER = 64 -- (In Bytes)

data MzHeader = MzHeader
  { _magic :: Word16
  , _cblp :: Word16
  , _cp :: Word16
  , _crlc :: Word16
  , _cparhdr :: Word16
  , _minalloc :: Word16
  , _maxalloc :: Word16
  , _ss :: Word16
  , _sp :: Word16
  , _csum :: Word16
  , _ip :: Word16
  , _cs :: Word16
  , _lrarlc :: Word16
  , _ovno :: Word16
  , _res :: Res1
  , _oemid :: Word16
  , _oeminfo :: Word16
  , _res2 :: Res2
  , _lfanew :: Word32
  } deriving (Show, Eq, Ord)

data Res1 = Res1
  { _res1_0 :: Word16
  , _res1_1 :: Word16
  , _res1_2 :: Word16
  , _res1_3 :: Word16
  } deriving (Show, Eq, Ord)

data Res2 = Res2
  { _res2_0 :: Word16
  , _res2_1 :: Word16
  , _res2_2 :: Word16
  , _res2_3 :: Word16
  , _res2_4 :: Word16
  , _res2_5 :: Word16
  , _res2_6 :: Word16
  , _res2_7 :: Word16
  , _res2_8 :: Word16
  , _res2_9 :: Word16
  } deriving (Show, Eq, Ord)

-- | Automatically derive a lense for the MzHeader data type.  Which
--   provides getters and setters for that data type.
mkLabels [''MzHeader, ''Res1, ''Res2] 

\end{code}
